package com.morningstar.qs.basic.db.dto;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

import com.morningstar.qs.api.basic.util.DatetimeUtil;
import com.morningstar.qs.basic.db.bean.Exchanges;

public class ExchangesDto extends Exchanges implements Serializable {
	
	private int gmtOffsetByMinute;

	private static final long serialVersionUID = -196088503894473261L;
	private final Map<Integer, MarketsDto> marks=new HashMap<Integer, MarketsDto>();

	public ExchangesDto() {
		super();
	}

	public ExchangesDto(int id, int excId, String shortName, String timezoneId,
			String name, String micCode, String description) {
		super(id, excId, shortName, timezoneId, name, micCode, description);
	}
	
	public void addMarkets(MarketsDto m) {
		if(m==null) throw new IllegalArgumentException();
		marks.put(m.getSecuType(), m);
	}

	public MarketsDto getMarket(int secu) {
		return marks.get(secu);
	}

	public int getGmtOffsetByMinute() {
		return gmtOffsetByMinute;
	}

	public void setGmtOffsetByMinute(int gmtOffsetByMinute) {
		this.gmtOffsetByMinute = gmtOffsetByMinute;
	}

	@Override
	public void setTimezoneId(String timezoneId) {
		super.setTimezoneId(timezoneId);
		if(getTimezoneId()!=null) gmtOffsetByMinute= DatetimeUtil.gmtOffset(timezoneId);
	}
	

}
